using Microsoft.EntityFrameworkCore;
using Admin3000.Backend.Api.Entity;

namespace Admin3000.Backend.Api.Database
{
    /// <summary>
    /// 数据库上下文，这里定义这些实体对应的数据表、及连接参数
    /// </summary>
    public class Admin3000Db : DbContext
    {
        /// <summary>
        /// 采用依赖注入的方式的时，必须提供其构造函数，并且调用其父类构造函数
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public Admin3000Db(DbContextOptions options) : base(options)
        {

        }
        public DbSet<Users> Users { get; set; }
        public DbSet<Articles> Articles { get; set; }
        public DbSet<Comments> Comments { get; set; }
        public DbSet<AuditInfo> AuditInfo { get; set; }
        public DbSet<ArticleComments> ArticleComments{get;set;}
        public DbSet<UserComment> UserComments{get;set;}

        protected override void OnConfiguring(DbContextOptionsBuilder options)
        
            // options.UseSqlServer(@"server=.;database=Admin3000Db;uid=sa;pwd=123456");
            => options.UseNpgsql(@"uid=postgres;pwd=Gph17689974706;Host=47.115.139.93;Database=Admin3000Db2");
        // protected override void OnModelCreating(ModelBuilder modelBuilder){
        //     modelBuilder.Entity<Users>().HasData(
        //         new Users{
        //             Id=1,
        //             Username="admin",
        //             Password="113",
        //             IsActived = true,
        //             IsDeleted=false,
        //             CreatedTime = System.DateTime.Now,
        //             UpdatedTime = System.DateTime.Now,
        //             Remarks = null
        //         }
        //     );
        // }
    }
}